﻿namespace NMortgage.UI.Tests
{
    using System;

    using FluentValidation.TestHelper;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using NMortgage.UI.Model;

    [TestClass]
    public class InterestParametersValidatorTest
    {
        #region Properties

        InterestParametersValidator Subject
        {
            get;
            set;
        }

        private InterestParameterCollection GetValidTarget()
        {
            InterestParameterCollection p = new InterestParameterCollection();
            p = new InterestParameterCollection();
            p.Add(InterestParametersTest.GetParameter0());
            p.Add(InterestParametersTest.GetInvalidParameter0());

            return p;
        }

        private InterestParameterCollection GetInvalidTarget()
        {
            InterestParameterCollection p = new InterestParameterCollection();            
            p = new InterestParameterCollection();
            p.Add(InterestParametersTest.GetParameter0());
            p.Add(InterestParametersTest.GetInvalidParameter0());

            return p;
        }

        #endregion Properties

        #region Methods

        [TestMethod]
        public void HaveValidChildrenTest()
        {
            InterestParameterCollection validationTarget = GetInvalidTarget();

            bool expected = false;
            bool actual = Subject.HaveValidChildren(validationTarget, 0);
            Assert.AreEqual(expected, actual);


            validationTarget.Clear();
            validationTarget.Add(InterestParametersTest.GetParameter0());
            validationTarget.Add(InterestParametersTest.GetParameter1());
            validationTarget.Add(InterestParametersTest.GetParameter2());

            expected = true;
            actual = Subject.HaveValidChildren(validationTarget, 0);
            Assert.AreEqual(expected, actual);

            validationTarget.Add(InterestParametersTest.GetInvalidParameter0());
            expected = false;
            actual = Subject.HaveValidChildren(validationTarget, 0);
            Assert.AreEqual(expected, actual);
        }

        [TestInitialize]
        public void InitTest()
        {
            Subject = new InterestParametersValidator();

        }

        [TestMethod]
        public void Empty_list_should_not_be_valid()
        {
            InterestParameterCollection validationTarget = GetValidTarget();
            validationTarget.Clear();
            bool expected = false;
            bool actual = Subject.Validate(validationTarget).IsValid;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void InterestParametersValidatorConstructorTest()
        {
            InterestParametersValidator target = new InterestParametersValidator();
            Assert.IsNotNull(target);
        }

        #endregion Methods
    }
}